
*******************************************************
**Table 1
*******************************************************
*Generate a variable that defines the sample
#delimit ; 
local controled AGE agefirstconceptionUSE agelt15 hispanic black white protestant catholic
workingmother hasworkingmother momeduc hasmomeduc liveboth14 survey1973 survey1976 survey1982 
survey1988;

reg nevermarried firstpregbirthdk `controled'   if  abort~=1
& (pregnum==1|survey==1973) & teenpregearlypd==. [pw=wtuse], r;
gen sampnevermarried = e(sample)==1;

replace familyincome = 18499 if familyincome == 17999;
drop lnfamincome;
gen lnfamincome = ln(familyincome);
***********
#delimit ;

svyset [pweight=wtuse];

local allvars educ educatl12 agefirstmarriage infirstmarr marrafterfirst nevermarried numchildren
working 
familyincome increlpoverty AGE agefirstconceptionUSE agelt15 hispanic black white protestant catholic
educpredict2 educpredict2resc survey1973 survey1976 survey1982 survey1988;

#delimit cr
foreach y of local allvars{
tabout firstpregbirthdk if sampnevermarried==1 & marrpreconceptdateUSE==1 [aw=wtuse] using sumstatsdk11mar14pre1969.xls, append c(mean `y' sd `y') f(2) clab(Mean_`y' SD) layout(row) sum npos(both)
tabout firstpregbirthdk if sampnevermarried==1 & marrpreconceptdateUSE==0 & havemarrpreconceptdate==1 [aw=wtuse] using sumstatsdk11mar14pre1969.xls, append c(mean `y' sd `y') f(2) clab(Mean_`y' SD) layout(row) sum npos(both)
}

tabout firstpregbirthdk if sampnevermarried==1 & marrpreconceptdateUSE==1 [aw=wtuse] using sumstatsdkmarr11mar14pre1969.xls, append c(mean marrafterfirst sd marrafterfirst) f(2) clab(Mean_marrafterfirst SD) layout(row) sum npos(both)
tabout firstpregbirthdk if sampnevermarried==1 & marrpreconceptdateUSE==0 & havemarrpreconceptdate==1 [aw=wtuse] using sumstatsdkmarr11mar14pre1969.xls, append c(mean marrafterfirst sd marrafterfirst) f(2) clab(Mean_marrafterfirst SD) layout(row) sum npos(both)

*Now get the standard errors on the difference
#delimit cr

#delimit ;
local allvars educ educatl12 agefirstmarriage infirstmarr marrafterfirst nevermarried numchildren working 
familyincome increlpoverty AGE agefirstconceptionUSE agelt15 hispanic black white protestant catholic
educpredict2 educpredict2resc survey1973 survey1976 survey1982 survey1988;
#delimit cr
foreach y of local allvars{
reg `y' firstpregbirthdk if sampnevermarried==1 & marrpreconceptdateUSE==1 [pw=wtuse],r
reg `y' firstpregbirthdk if sampnevermarried==1 & marrpreconceptdateUSE==0 & havemarrpreconceptdate==1 [pw=wtuse],r
}

*Get counts for variables with missings
count if sampnevermarried==1 & firstpregbirthdk==1 & educ~=. & marrpreconceptdateUSE==1

*Need to do mean separately for liveboth14, because not in the 1995 survey

su liveboth14 if sampnevermarried==1  & survey~=1995  & firstpregbirthdk==1 & marrpreconceptdateUSE==1 [aw=wtuse]
su liveboth14 if sampnevermarried==1  & survey~=1995  & firstpregbirthdk==1 & marrpreconceptdateUSE==0 & havemarrpreconceptdate==1 [aw=wtuse]

su liveboth14 if sampnevermarried==1  & survey~=1995  & firstpregbirthdk==0 & marrpreconceptdateUSE==1 [aw=wtuse]
su liveboth14 if sampnevermarried==1  & survey~=1995  & firstpregbirthdk==0 & marrpreconceptdateUSE==0 & havemarrpreconceptdate==1  [aw=wtuse]

reg liveboth14 firstpregbirthdk if sampnevermarried==1 & survey~=1995 & marrpreconceptdateUSE==1 [pw=wtuse]
reg liveboth14 firstpregbirthdk if sampnevermarried==1 & survey~=1995 & marrpreconceptdateUSE==0 & havemarrpreconceptdate==1  [pw=wtuse]

*Also need to do separately for momeduc and workingmother since need to condition
*on non-missing

local expl momeduc workingmother
foreach y of local expl{
su `y' if sampnevermarried==1  & firstpregbirthdk==1 & has`y'==1 & marrpreconceptdateUSE==1 [aw=wtuse]
su `y' if sampnevermarried==1  & firstpregbirthdk==1 & has`y'==1 & marrpreconceptdateUSE==0 & havemarrpreconceptdate==1  [aw=wtuse]

su `y' if sampnevermarried==1  & firstpregbirthdk==0 & has`y'==1 & marrpreconceptdateUSE==1 [aw=wtuse]
su `y' if sampnevermarried==1  & firstpregbirthdk==0 & has`y'==1 & marrpreconceptdateUSE==0 & havemarrpreconceptdate==1  [aw=wtuse]

reg `y' firstpregbirthdk if sampnevermarried==1 & survey~=1995 & has`y'==1 & marrpreconceptdateUSE==1 [pw=wtuse], r
reg `y' firstpregbirthdk if sampnevermarried==1 & survey~=1995 & has`y'==1 & marrpreconceptdateUSE==0 & havemarrpreconceptdate==1 [pw=wtuse], r
}




**********************************************************
*Table 2
**********************************************************

#delimit ;

local controled agefirstconceptionUSE i.agelt15 i.hispanic i.black i.white i.protestant 
i.catholic
i.workingmother i.hasworkingmother momeduc i.hasmomeduc i.liveboth14 i.survey1973 i.survey1976 i.survey1982 
i.survey1988 year1concept;

reg firstpregbirthdk marrpreconceptdateUSE havemarrpreconceptdate `controled' 
if  abort~=1 & (pregnum==1|survey==1973) & teenpregearlypd==. [pw=wtuse], r;
test 1.survey1973 1.survey1976 1.survey1982 1.survey1988;
outreg2 using predmiscarriagedk10mar14pre1969resc.xls, replace dec(3) drop(havemarrpreconceptdate);

probit firstpregbirthdk marrpreconceptdateUSE havemarrpreconceptdate `controled' 
if  abort~=1 & (pregnum==1|survey==1973) & teenpregearlypd==. [pw=wtuse], r;
test 1.survey1973 1.survey1976 1.survey1982 1.survey1988;
margins, dydx(*) post;
outreg2 using predmiscarriagedk10mar14pre1969resc.xls, append dec(3) drop(havemarrpreconceptdate);

logit firstpregbirthdk marrpreconceptdateUSE havemarrpreconceptdate `controled' 
if  abort~=1 & (pregnum==1|survey==1973) & teenpregearlypd==. [pw=wtuse], r;
test 1.survey1973 1.survey1976 1.survey1982 1.survey1988;
margins, dydx(*) post;
outreg2 `outreg' using predmiscarriagedk10mar14pre1969resc.xls, append dec(3) drop(havemarrpreconceptdate);

*Check whether the coefficients on the survey year are significant by leaving out the
*indicators for working mother non-missing and mother's education non-missing--these are highly collinear
*with survey year;

local controled agefirstconceptionUSE i.agelt15 i.hispanic i.black i.white i.protestant 
i.catholic i.liveboth14 i.survey1973 i.survey1976 i.survey1982 
i.survey1988 year1concept;

reg firstpregbirthdk marrpreconceptdateUSE havemarrpreconceptdate `controled' 
if  abort~=1 & (pregnum==1|survey==1973) & teenpregearlypd==. [pw=wtuse], r;
test 1.survey1973 1.survey1976 1.survey1982 1.survey1988;
outreg2 using predmiscarriagedk10mar14pre1969resc.xls, append dec(3) drop(havemarrpreconceptdate);


***********************************************;
*Table 3;
***********************************************;

#delimit ;
local outcome educ educatl12 agefirstmarriage nevermarried infirstmarr marrafterfirst
numchildren  working lnfamincome increlpoverty;

local controled AGE agefirstconceptionUSE agelt15 hispanic black white protestant catholic
workingmother hasworkingmother momeduc hasmomeduc liveboth14 survey1973 survey1976 survey1982 
survey1988;

foreach y of local outcome{;
reg `y' firstpregbirthdk birthmarrpreconceptdate marrpreconceptdateUSE `controled' havemarrpreconceptdate 
if  abort~=1 & (pregnum==1|survey==1973) & teenpregearlypd==. [pw=wtuse], r;
test firstpregbirthdk birthmarrpreconceptdate;
local ptest = r(p);
lincom firstpregbirthdk + birthmarrpreconceptdate;
local lincomcoeff = r(estimate);
local lincomse = r(se);
su `y' if e(sample)==1 [aw=wtuse];
local meanvar = r(mean);
outreg2 using regsdkmarrpreconceptdate2mar2014.xls, addstat(ptest, `ptest',
lincom, `lincomcoeff',
lincomse, `lincomse', meanvar, `meanvar') append excel br dec(2) adec(2);
};

reg nevermarried firstpregbirthdk  `controled' 
if  abort~=1 & (pregnum==1|survey==1973) & teenpregearlypd==. & marrpreconceptdateUSE==0 & havemarrpreconceptdate==1 [pw=wtuse], r;
su nevermarried if e(sample)==1 [aw=wtuse];
local meanvar = r(mean);
outreg2 using regsdkmarrpreconceptdate2mar2014.xls, addstat(meanvar, `meanvar') append excel br dec(2);

**Control for number of children in remarriage regression;
#delimit ;
local controled AGE agefirstconceptionUSE agelt15 hispanic black white protestant catholic
workingmother momeduc liveboth14 survey1973 survey1976 survey1982 
survey1988 hasworkingmother hasmomeduc;

reg infirstmarr firstpregbirthdk birthmarrpreconceptdate marrpreconceptdateUSE numchildren
`controled' havemarrpreconceptdate
if  abort~=1 & (pregnum==1|survey==1973) & teenpregearlypd==. [pw=wtuse], r;

*Control for working/married in the income regression;

#delimit ;
local controled AGE agefirstconceptionUSE agelt15 hispanic black white protestant catholic
workingmother momeduc liveboth14 survey1973 survey1976 survey1982 
survey1988 hasworkingmother hasmomeduc;

reg lnfamincome firstpregbirthdk birthmarrpreconceptdate marrpreconceptdateUSE working
`controled' havemarrpreconceptdate
if  abort~=1 & (pregnum==1|survey==1973) & teenpregearlypd==. [pw=wtuse], r;

reg lnfamincome firstpregbirthdk birthmarrpreconceptdate marrpreconceptdateUSE married
`controled' havemarrpreconceptdate
if  abort~=1 & (pregnum==1|survey==1973) & teenpregearlypd==. [pw=wtuse], r;

***************************************************;
*Table 4;
***************************************************;

foreach y of local outcome{;
bootstrap _b[firstpregbirthdk] _b[birthdkeducpredict2resc] 
_b[birthprededmarrpreconceptdate] _b[birthmarrpreconceptdate] _b[prededmarrpreconceptdate], reps(500) 
saving("bs`y'.dta", replace) force seed(246899) nodots:
reg `y' `controled'  firstpregbirthdk birthdkeducpredict2resc
birthprededmarrpreconceptdate birthmarrpreconceptdate prededmarrpreconceptdate marrpreconceptdateUSE 
havemarrpreconceptdate if abort~=1
& (pregnum==1|survey==1973) & teenpregearlypd==. [pw=wtuse], r;
test _bs_1 _bs_2 _bs_3 _bs_4;
local ptestmarrpreconcept =r(p);
test _bs_1 _bs_2;
local ptestnomarrpreconcept =r(p);
lincom _b[_bs_1] -2*_b[_bs_2] -2*_b[_bs_3] +_b[_bs_4];
local lincomcoeff10marrpreconcept = r(estimate);
local lincomse10marrpreconcept = r(se);
lincom _b[_bs_1] -2*_b[_bs_2];
local lincomcoeff10nomarrpreconcept = r(estimate);
local lincomse10nomarrpreconcept = r(se);
lincom _b[_bs_1] + 2*_b[_bs_2] + 2*_b[_bs_3] +_b[_bs_4];
local lincomcoeff14marrpreconcept = r(estimate);
local lincomse14marrpreconcept = r(se);
lincom _b[_bs_1] + 2*_b[_bs_2];
local lincomcoeff14nomarrpreconcept = r(estimate);
local lincomse14nomarrpreconcept = r(se);
lincom _b[_bs_1] + _b[_bs_4];
local lincomcoeff12marrpreconcept = r(estimate);
local lincomse12marrpreconcept = r(se);
outreg2 using regsdkmarrpreconceptdatewithprededlin24feb14pre1969resc.xls, addstat(ptestmarrpreconcept, 
`ptestmarrpreconcept', ptestnomarrpreconcept, `ptestnomarrpreconcept',
lincom10marrpreconcept, `lincomcoeff10marrpreconcept',
lincom10semarrpreconcept, `lincomse10marrpreconcept',
lincom10nomarrpreconcept, `lincomcoeff10nomarrpreconcept',
lincom10senomarrpreconcept, `lincomse10nomarrpreconcept',  
lincom14marrpreconcept, `lincomcoeff14marrpreconcept',
lincom14semarrpreconcept, `lincomse14marrpreconcept',
lincom14nomarrpreconcept, `lincomcoeff14nomarrpreconcept',
lincom14senomarrpreconcept, `lincomse14nomarrpreconcept',
lincom12marrpreconcept, `lincomcoeff12marrpreconcept',
lincom12semarrpreconcept, `lincomse12marrpreconcept') append excel br dec(2) adec(2);
};

bootstrap _b[firstpregbirthdk] _b[birthdkeducpredict2resc], reps(500) 
saving("bs`y'.dta", replace) force seed(246899) nodots:
reg nevermarried `controled'  firstpregbirthdk birthdkeducpredict2resc
if marrpreconceptdateUSE==0 & havemarrpreconceptdate==1 & abort~=1
& (pregnum==1|survey==1973) & teenpregearlypd==. [pw=wtuse], r;
test _bs_1 _bs_2;
local ptest =r(p);
lincom _b[_bs_1] -2*_b[_bs_2];
local lincomcoeff10nomarrpreconcept = r(estimate);
local lincomse10nomarrpreconcept = r(se);
lincom _b[_bs_1] + 2*_b[_bs_2];
local lincomcoeff14nomarrpreconcept = r(estimate);
local lincomse14nomarrpreconcept = r(se);
outreg2 using regsdkmarrpreconceptdatewithprededlin24feb14pre1969resc.xls, addstat(ptest, `ptest',
lincom10nomarrpreconcept, `lincomcoeff10nomarrpreconcept',
lincom10senomarrpreconcept, `lincomse10nomarrpreconcept',  
lincom14nomarrpreconcept, `lincomcoeff14nomarrpreconcept',
lincom14senomarrpreconcept, `lincomse14nomarrpreconcept') append excel br dec(2) adec(2);

****************************************;
**Table 5;
****************************************;

local outcome educ educatl12 agefirstmarriage infirstmarr marrafterfirst
numchildren lnfamincome working increlpoverty;

local controled agefirstconceptionUSE agelt15 hispanic black white protestant catholic
workingmother momeduc liveboth14 survey1973 survey1976 survey1982 
survey1988 hasworkingmother hasmomeduc;

foreach y of local outcome{;
reg `y' firstpregbirthdk  birthdate1960 
birthdate1960marrpreconcept birthmarrpreconceptdate date1960marrpreconcept date1concept
 `controled'
marrpreconceptdateUSE havemarrpreconceptdate  if  abort~=1
& (pregnum==1|survey==1973) & teenpregearlypd==. [pw=wtuse], r;
test firstpregbirthdk birthdate1960;
local ptestnomarrpreconcept = r(p);
test firstpregbirthdk birthdate1960 birthdate1960marrpreconcept birthmarrpreconceptdate;
local ptestmarrpreconcept = r(p);
lincom firstpregbirthdk - 8*birthdate1960;
local lincomcoeff1952nomarrpreconcept = r(estimate);
local lincomse1952nomarrpreconcept = r(se);
lincom firstpregbirthdk + 8*birthdate1960;
local lincomcoeff1968nomarrpreconcept = r(estimate);
local lincomse1968nomarrpreconcept = r(se);
*Marr Pre Concept;
lincom firstpregbirthdk - 8*birthdate1960 -8*birthdate1960marrpreconcept + birthmarrpreconceptdate;
local lincomcoeff1952marrpreconcept = r(estimate);
local lincomse1952marrpreconcept = r(se);
lincom firstpregbirthdk + birthmarrpreconceptdate;
local lincomcoeff1960marrpreconcept = r(estimate);
local lincomse1960marrpreconcept = r(se);
lincom firstpregbirthdk + 8*birthdate1960 +8*birthdate1960marrpreconcept + birthmarrpreconceptdate;
local lincomcoeff1968marrpreconcept = r(estimate);
local lincomse1968marrpreconcept = r(se);
outreg2 using regsdktimetrend2mar2014.xls, addstat(ptestnomarrpreconcept, `ptestnomarrpreconcept',
ptestmarrpreconcept, `ptestmarrpreconcept',
lincom1952nomarrpreconcept, `lincomcoeff1952nomarrpreconcept',
lincom1952nomarrpreconceptse, `lincomse1952nomarrpreconcept',  lincom1968nomarrpreconcept, `lincomcoeff1968nomarrpreconcept',
lincom1968nomarrpreconceptse, `lincomse1968nomarrpreconcept', lincom1952marrpreconcept, `lincomcoeff1952marrpreconcept',
lincom1952marrpreconceptse, `lincomse1952marrpreconcept', lincom1960marrpreconcept, `lincomcoeff1960marrpreconcept',
lincom1960marrpreconceptse, `lincomse1960marrpreconcept', lincom1968marrpreconcept, `lincomcoeff1968marrpreconcept',
lincom1968marrpreconceptse, `lincomse1968marrpreconcept') append excel br dec(3) adec(2);
};

*Need to do this separately for never married;
reg nevermarried firstpregbirthdk  birthdate1960 date1concept
 `controled' if  abort~=1
& (pregnum==1|survey==1973) & teenpregearlypd==. & marrpreconceptdateUSE==0 & havemarrpreconceptdate==1 [pw=wtuse], r;
test firstpregbirthdk birthdate1960;
local ptestnomarrpreconcept = r(p);
lincom firstpregbirthdk - 8*birthdate1960;
local lincomcoeff1952nomarrpreconcept = r(estimate);
local lincomse1952nomarrpreconcept = r(se);
lincom firstpregbirthdk + 8*birthdate1960;
local lincomcoeff1968nomarrpreconcept = r(estimate);
local lincomse1968nomarrpreconcept = r(se);
outreg2 using regsdktimetrend2mar2014.xls, addstat(ptestnomarrpreconcept, `ptestnomarrpreconcept',
lincom1952nomarrpreconcept, `lincomcoeff1952nomarrpreconcept',
lincom1952nomarrpreconceptse, `lincomse1952nomarrpreconcept',  lincom1968nomarrpreconcept, `lincomcoeff1968nomarrpreconcept',
lincom1968nomarrpreconceptse, `lincomse1968nomarrpreconcept') append excel br dec(3) adec(2);


***************************************;
*Table 6; 
***************************************;

local outcome educ educatl12 agefirstmarriage infirstmarr marrafterfirst nevermarried
numchildren working lnfamincome increlpoverty;

local controled agefirstconceptionUSE agelt15 hispanic black white protestant catholic
workingmother momeduc liveboth14 survey1973 survey1976 survey1982 
survey1988 hasworkingmother hasmomeduc;

foreach y of local outcome{;
reg `y' shotgunnew date1concept `controled' if  abort~=1 & (pregnum==1|survey==1973) & 
teenpregearlypd==. & firstpregbirthdk==1 & marrpreconceptdateUSE==0 & havemarrpreconceptdate==1 [pw=wtuse], r;
outreg2 using shotgun16mar2014.xls, append excel br dec(2);

reg `y' shotgunnew date1concept shotgundate1960 `controled' if  abort~=1 & (pregnum==1|survey==1973) & 
teenpregearlypd==. & firstpregbirthdk==1 & marrpreconceptdateUSE==0 & havemarrpreconceptdate==1 [pw=wtuse], r;
outreg2 using shotgun16mar2014.xls, append excel br dec(2);
};

#delimit ;
local controled agefirstconceptionUSE agelt15 hispanic black white protestant catholic
workingmother momeduc liveboth14 survey1973 survey1976 survey1982 
survey1988 hasworkingmother hasmomeduc;

reg lnfamincome working married shotgunnew date1concept `controled' if  abort~=1 & (pregnum==1|survey==1973) & 
teenpregearlypd==. & firstpregbirthdk==1 & marrpreconceptdateUSE==0 & havemarrpreconceptdate==1 [pw=wtuse], r;


*************************************************************;
**Appendix Table 1;
******************************************************************;

*Need to generate the predicted education just using 82, 88, 95;

#delimit ;
local controled AGE hispanic black white protestant catholic
workingmother hasworkingmother momeduc hasmomeduc liveboth14 survey1982 survey1988 survey1973
survey1976;

#delimit cr

reg educ `controled' if teenpregearlypd==0 & tagID==1 & survey>=1977 [pw=wtuse], r 
predict educpredict2orig

gen educpredict2origresc = educpredict2orig-12

gen birthdkeducpredict2rescorig = firstpregbirthdk*educpredict2origresc

*Now do the same for the restricted version. 

reg educ `controled' if teenpregearlypd==0 & tagID==1 & survey>=1977 & ((nevermarried~=0&nevermarried~=.)|totchildinhh>=1) [pw=wtuse], r 
predict educpredict2origchildinhh

gen educpredict2origchildinhhresc = educpredict2origchildinhh-12

gen birthdkedpred2origchildinhhresc = firstpregbirthdk*educpredict2origchildinhhresc

*Left-hand side of Appendix Table 1: without predicted education

#delimit ;

local outcome educ educatl12 agefirstmarriage infirstmarr marrafterfirst  nevermarried
numchildren working lnfamincome increlpoverty;

local controled AGE agefirstconceptionUSE agelt15 hispanic black white protestant catholic
workingmother hasworkingmother momeduc hasmomeduc liveboth14 survey1973 survey1976 survey1982 
survey1988;

foreach y of local outcome{;
reg `y' firstpregbirthdk `controled' if  abort~=1
& pregnum==1 & survey>=1977 &
teenpregearlypd==. [pw=wtuse], r;
outreg2 firstpregbirthdk using appendixrestr20mar14.xls, append excel br dec(2);
};

foreach y of local outcome{;
reg `y' firstpregbirthdk `controled' if  abort~=1
& pregnum==1 & survey>=1977 & ((nevermarried~=1 & nevermarried~=.)|totchildinhh>=1) &
teenpregearlypd==. [pw=wtuse], r;
outreg2 firstpregbirthdk using appendixrestr20mar14.xls, append excel br dec(2);
};

*Right-hand side of Appendix Table 1: include the interaction with predicted education;

foreach y of local outcome{;
bootstrap _b[firstpregbirthdk] _b[birthdkeducpredict2rescorig], reps(500) 
saving("bs`y'.dta", replace) force seed(246899) nodots:
reg `y' `controled'  firstpregbirthdk birthdkeducpredict2rescorig if abort~=1
& pregnum==1 & survey>=1977 &
teenpregearlypd==. [pw=wtuse], r;
test _bs_1 _bs_2;
local ptest =r(p);
lincom _b[_bs_1] -2*_b[_bs_2];
local lincomcoeff10 = r(estimate);
local lincomse10 = r(se);
lincom _b[_bs_1] + 2*_b[_bs_2];
local lincomcoeff14 = r(estimate);
local lincomse14 = r(se);
outreg2 using appendixrestr20mar14.xls, addstat(ptest, `ptest',
lincom10, `lincomcoeff10',
lincom10se, `lincomse10',  lincom14, `lincomcoeff14',
lincom14se, `lincomse14') append excel br dec(2) adec(2);
};

foreach y of local outcome{;
bootstrap _b[firstpregbirthdk] _b[birthdkedpred2origchildinhhresc], reps(500) 
saving("bs`y'.dta", replace) force seed(246899) nodots:
reg `y' `controled'  firstpregbirthdk birthdkedpred2origchildinhhresc if abort~=1
& pregnum==1 & survey>=1977 & ((nevermarried~=1 & nevermarried~=.)|totchildinhh>=1) &
teenpregearlypd==. [pw=wtuse], r;
test _bs_1 _bs_2;
local ptest =r(p);
lincom _b[_bs_1] -2*_b[_bs_2];
local lincomcoeff10 = r(estimate);
local lincomse10 = r(se);
lincom _b[_bs_1] + 2*_b[_bs_2];
local lincomcoeff14 = r(estimate);
local lincomse14 = r(se);
outreg2 using appendixrestr20mar14.xls, addstat(ptest, `ptest',
lincom10, `lincomcoeff10',
lincom10se, `lincomse10',  lincom14, `lincomcoeff14',
lincom14se, `lincomse14') append excel br dec(2) adec(2);
};
*******************************************;
*Other results referenced throughout the paper;
*******************************************;

#delimit cr

*Descriptive statistics of pre-marital conceptions and outcomes over time

tab marrpreconceptdateUSE if havemarrpreconceptdate ==1 & sampnevermarried==1 [aw=wtuse]
tab marrpreoutcome if havemarrpreconceptdate ==1 & sampnevermarried==1 [aw=wtuse]

tab marrpreconceptdateUSE if havemarrpreconceptdate ==1 & sampnevermarried==1 & year1concept<1950 & year1concept~=. [aw=wtuse]
tab marrpreconceptdateUSE if havemarrpreconceptdate ==1 & sampnevermarried==1 & year1concept>=1950 & year1concept<=1954 & year1concept~=. [aw=wtuse]
tab marrpreconceptdateUSE if havemarrpreconceptdate ==1 & sampnevermarried==1 & year1concept>=1955 & year1concept<=1959 & year1concept~=. [aw=wtuse]
tab marrpreconceptdateUSE if havemarrpreconceptdate ==1 & sampnevermarried==1 & year1concept>=1960 & year1concept<=1964 & year1concept~=. [aw=wtuse]
tab marrpreconceptdateUSE if havemarrpreconceptdate ==1 & sampnevermarried==1 & year1concept>=1965 & year1concept<=1968 & year1concept~=. [aw=wtuse]

tab marrpreoutcome if havemarrpreconceptdate ==1 & sampnevermarried==1 & year1concept<1950 & year1concept~=. [aw=wtuse]
tab marrpreoutcome if havemarrpreconceptdate ==1 & sampnevermarried==1 & year1concept>=1950 & year1concept<=1954 & year1concept~=. [aw=wtuse]
tab marrpreoutcome if havemarrpreconceptdate ==1 & sampnevermarried==1 & year1concept>=1955 & year1concept<=1959 & year1concept~=. [aw=wtuse]
tab marrpreoutcome if havemarrpreconceptdate ==1 & sampnevermarried==1 & year1concept>=1960 & year1concept<=1964 & year1concept~=. [aw=wtuse]
tab marrpreoutcome if havemarrpreconceptdate ==1 & sampnevermarried==1 & year1concept>=1965 & year1concept<=1968 & year1concept~=. [aw=wtuse]

tab shotgunnew if havemarrpreconceptdate ==1 & marrpreconceptdateUSE==0 & sampnevermarried==1 & year1concept<1950 & year1concept~=. [aw=wtuse]
tab shotgunnew if havemarrpreconceptdate ==1 & marrpreconceptdateUSE==0 & sampnevermarried==1 & year1concept>=1950 & year1concept<=1954 & year1concept~=. [aw=wtuse]
tab shotgunnew if havemarrpreconceptdate ==1 & marrpreconceptdateUSE==0 & sampnevermarried==1 & year1concept>=1955 & year1concept<=1959 & year1concept~=. [aw=wtuse]
tab shotgunnew if havemarrpreconceptdate ==1 & marrpreconceptdateUSE==0 & sampnevermarried==1 & year1concept>=1960 & year1concept<=1964 & year1concept~=. [aw=wtuse]
tab shotgunnew if havemarrpreconceptdate ==1 & marrpreconceptdateUSE==0 & sampnevermarried==1 & year1concept>=1965 & year1concept<=1968 & year1concept~=. [aw=wtuse]

tab shotgunnew if sampnevermarried==1 & marrpreconceptdateUSE==0 & havemarrpreconceptdate==1 [aw=wtuse]

*Look at changing composition of pregnant teens

reg white year1concept if sampnevermarried==1  & marrpreconceptdateUSE==0 & havemarrpreconceptdate==1 & year1concept>=1960 & year1concept<=1968 [aw=wtuse]

#delimit ;
reg educatl12 year1concept if sampnevermarried==1  & marrpreconceptdateUSE==0 & havemarrpreconceptdate==1 & year1concept>=1960 & 
year1concept<=1968 & firstpregbirthdk==0 [aw=wtuse];

#delimit cr

*Adoptions

su adopted if sampnevermarried==1 & firstpregbirthdk==1 & survey==1973 [aw=wtuse]
tab adopted if sampnevermarried==1 & firstpregbirthdk==1 & survey==1973 [aw=wtuse], missing

su adopted if sampnevermarried==1 & firstpregbirthdk==1 & survey==1976 [aw=wtuse]
tab adopted if sampnevermarried==1 & firstpregbirthdk==1 & survey==1976 [aw=wtuse], missing

su adopted if sampnevermarried==1 & firstpregbirthdk==1 & survey==1982 [aw=wtuse]
tab adopted if sampnevermarried==1 & firstpregbirthdk==1 & survey==1982 [aw=wtuse], missing

su adopted if sampnevermarried==1 & firstpregbirthdk==1 & survey==1988 [aw=wtuse]
tab adopted if sampnevermarried==1 & firstpregbirthdk==1 & survey==1988 [aw=wtuse], missing

su adopted if sampnevermarried==1 & firstpregbirthdk==1 & survey==1995 [aw=wtuse]
tab adopted if sampnevermarried==1 & firstpregbirthdk==1 & survey==1995 [aw=wtuse], missing

*Compare predicted to actual education for miscarriages--Footnote 19
su educpredict2 if firstpregbirthdk==0 & sampnevermarried==1 [aw=wtuse]
su educ if firstpregbirthdk==0 & sampnevermarried==1 [aw=wtuse]

reg educ educpredict2 if firstpregbirthdk==0 & sampnevermarried==1 [pw=wtuse], r
test educpredict2=1

#delimit ;

**Remove Hispanics-Footnote 25;

#delimit ;
local outcome educ educatl12 agefirstmarriage infirstmarr marrafterfirst
numchildren lnfamincome working;

local controled AGE agefirstconceptionUSE agelt15 hispanic black white protestant catholic
workingmother momeduc liveboth14 survey1973 survey1976 survey1982 
survey1988 hasworkingmother hasmomeduc;

foreach y of local outcome{;
reg `y' firstpregbirthdk birthmarrpreconceptdate marrpreconceptdateUSE `controled' havemarrpreconceptdate 
if  abort~=1 & (pregnum==1|survey==1973) & teenpregearlypd==. & hispanic==0 [pw=wtuse], r;
test firstpregbirthdk birthmarrpreconceptdate;
local ptest = r(p);
lincom firstpregbirthdk + birthmarrpreconceptdate;
local lincomcoeff = r(estimate);
local lincomse = r(se);
outreg2 using regsdkmarrpreconceptdate2mar2014nohisp.xls, addstat(ptest, `ptest',
lincom, `lincomcoeff',
lincomse, `lincomse') append excel br dec(2) adec(2);
};

reg nevermarried firstpregbirthdk  `controled' 
if  abort~=1 & (pregnum==1|survey==1973) & teenpregearlypd==. & marrpreconceptdateUSE==0 & havemarrpreconceptdate==1 [pw=wtuse], r;
outreg2 using regsdkmarrpreconceptdate2mar2014nohisp.xls, append excel br dec(2);

*Exclude Hispanics and interact birth with predicted education;

foreach y of local outcome{;
bootstrap _b[firstpregbirthdk] _b[birthdkeducpredict2resc] 
_b[birthprededmarrpreconceptdate] _b[birthmarrpreconceptdate] _b[prededmarrpreconceptdate], reps(500) 
saving("bs`y'.dta", replace) force seed(246899) nodots:
reg `y' `controled'  firstpregbirthdk birthdkeducpredict2resc
birthprededmarrpreconceptdate birthmarrpreconceptdate prededmarrpreconceptdate marrpreconceptdateUSE 
havemarrpreconceptdate if abort~=1
& (pregnum==1|survey==1973) & teenpregearlypd==. & hispanic==0 [pw=wtuse], r;
test _bs_1 _bs_2 _bs_3 _bs_4;
local ptestmarrpreconcept =r(p);
test _bs_1 _bs_2;
local ptestnomarrpreconcept =r(p);
lincom _b[_bs_1] -2*_b[_bs_2] -2*_b[_bs_3] +_b[_bs_4];
local lincomcoeff10marrpreconcept = r(estimate);
local lincomse10marrpreconcept = r(se);
lincom _b[_bs_1] -2*_b[_bs_2];
local lincomcoeff10nomarrpreconcept = r(estimate);
local lincomse10nomarrpreconcept = r(se);
lincom _b[_bs_1] + 2*_b[_bs_2] + 2*_b[_bs_3] +_b[_bs_4];
local lincomcoeff14marrpreconcept = r(estimate);
local lincomse14marrpreconcept = r(se);
lincom _b[_bs_1] + 2*_b[_bs_2];
local lincomcoeff14nomarrpreconcept = r(estimate);
local lincomse14nomarrpreconcept = r(se);
lincom _b[_bs_1] + _b[_bs_4];
local lincomcoeff12marrpreconcept = r(estimate);
local lincomse12marrpreconcept = r(se);
outreg2 using regsdkmarrpreconceptdatewithprededlin24feb14pre1969rescnohisp.xls, addstat(ptestmarrpreconcept, 
`ptestmarrpreconcept', ptestnomarrpreconcept, `ptestnomarrpreconcept',
lincom10marrpreconcept, `lincomcoeff10marrpreconcept',
lincom10semarrpreconcept, `lincomse10marrpreconcept',
lincom10nomarrpreconcept, `lincomcoeff10nomarrpreconcept',
lincom10senomarrpreconcept, `lincomse10nomarrpreconcept',  
lincom14marrpreconcept, `lincomcoeff14marrpreconcept',
lincom14semarrpreconcept, `lincomse14marrpreconcept',
lincom14nomarrpreconcept, `lincomcoeff14nomarrpreconcept',
lincom14senomarrpreconcept, `lincomse14nomarrpreconcept',
lincom12marrpreconcept, `lincomcoeff12marrpreconcept',
lincom12semarrpreconcept, `lincomse12marrpreconcept') append excel br dec(2) adec(2);
};

bootstrap _b[firstpregbirthdk] _b[birthdkeducpredict2resc], reps(500) 
saving("bs`y'.dta", replace) force seed(246899) nodots:
reg nevermarried `controled'  firstpregbirthdk birthdkeducpredict2resc
if marrpreconceptdateUSE==0 & havemarrpreconceptdate==1 & abort~=1
& (pregnum==1|survey==1973) & teenpregearlypd==. & hispanic==0 [pw=wtuse], r;
test _bs_1 _bs_2;
local ptest =r(p);
lincom _b[_bs_1] -2*_b[_bs_2];
local lincomcoeff10nomarrpreconcept = r(estimate);
local lincomse10nomarrpreconcept = r(se);
lincom _b[_bs_1] + 2*_b[_bs_2];
local lincomcoeff14nomarrpreconcept = r(estimate);
local lincomse14nomarrpreconcept = r(se);
outreg2 using regsdkmarrpreconceptwithprededlin24feb14pre1969rescnohisp.xls, addstat(ptest, `ptest',
lincom10nomarrpreconcept, `lincomcoeff10nomarrpreconcept',
lincom10senomarrpreconcept, `lincomse10nomarrpreconcept',  
lincom14nomarrpreconcept, `lincomcoeff14nomarrpreconcept',
lincom14senomarrpreconcept, `lincomse14nomarrpreconcept') append excel br dec(2) adec(2);

#delimit cr

*Likelihood of reporting pre-marital conceptions--Footnote 27

reg marrpreconceptdateUSE date1concept survey1973 survey1976 survey1982 survey1988 if havemarrpreconceptdate==1 & sampnevermarried==1 [pw=wtuse], r
test survey1973 survey1976 survey1982 survey1988

#delimit ;
local controled agefirstconceptionUSE agelt15 hispanic black white protestant catholic
workingmother momeduc liveboth14 survey1973 survey1976 survey1982 
survey1988 hasworkingmother hasmomeduc;

reg marrpreconceptdateUSE date1concept
`controled' if havemarrpreconceptdate==1 & sampnevermarried==1 [pw=wtuse], r;

test survey1973 survey1976 survey1982 survey1988;

#delimit cr

********************************************
*Bounds on incorrect values for married before conception due to imputing 
*missing months---reported in text of Data Appendix
********************************************

*In 1976
#delimit ;
tab monthsbetwmarrconcept survey if cmmissingmonth~=. & sampnevermarried==1 & 
havemarrpreconceptdate==1;
*In 1982;
#delimit ;
tab monthsbetwmarrconcept if DATE1CON>=9622 & DATE1CON<=9940 & sampnevermarried==1
 & survey==1982 & havemarrpreconceptdate==1;
*In 1988 both the date of conception and the marriage date are imputed;
#delimit ;
tab monthsbetwmarrconcept if ((DATE1CON>=90683 & DATE1CON<=91064)|(FMAR1MO>=90726)) 
& sampnevermarried==1 & survey==1988 & havemarrpreconceptdate==1;
*Only need to look at within 12 months if both dates are imputed;
#delimit ;
tab monthsbetwmarrconcept if ((DATE1CON>=90683 & DATE1CON<=91064)&(FMAR1MO>=90726)) 
& sampnevermarried==1 & survey==1988 & havemarrpreconceptdate==1;
*In 1995, no imputations;

#delimit cr

************************************************
*Bounds on incorrect values for married before outcome due to imputing 
*missing months---reported in text of Data Appendix
************************************************

*In 1976
#delimit ;
tab monthsbetwmarroutcome survey if cmmissingmonth~=. & sampnevermarried==1
& havemarrpreconceptdate==1;
*In 1982;
#delimit ;
tab monthsbetwmarroutcome if B22A>=9630 & B22A~=9797 & B22A~=9898 & B22A~=9999 &
sampnevermarried==1 & survey==1982 & havemarrpreconceptdate==1;
*In 1988 both the date of conception and the marriage date are imputed;
#delimit ;
tab monthsbetwmarroutcome if ((B14MO>=90714)|(FMAR1MO>=90726))
& sampnevermarried==1 & survey==1988 & havemarrpreconceptdate==1;
*Only need to look at 12 months if both dates are imputed;
tab monthsbetwmarroutcome if ((B14MO>=90714)&(FMAR1MO>=90726))
& sampnevermarried==1 & survey==1988 & havemarrpreconceptdate==1;
*In 1995, no imputations;
